home *** CD-ROM | disk | FTP | other *** search
/ Gekkan Dennou Club 142 / Gekkan Dennou Club - 2000.3 Vol. 142 (Japan).7z / Gekkan Dennou Club - 2000.3 Vol. 142 (Japan) (Track 1).bin / tools / s_tool / str.c < prev    next >
Text File  |  1999-06-08  |  12KB  |  578 lines

  1. #include    "JX250.H"
  2. #include    <sys\iocs.h>
  3. #include    <sys\dos.h>
  4. #include    <sys\scsi.h>
  5. #include    <stdio.h>
  6. #include    <stdlib.h>
  7. #include    <math.h>
  8. #include    <_tnb.c>
  9.  
  10.  
  11. /******************************************************
  12.     数値プリント(ito3a付き)
  13. ******************************************************/
  14. void    p_12_ito3a(x,y,d)
  15. int    x,y,d;
  16. {
  17. char    buf[16];
  18. ito3a(d,buf);
  19. p_12W(x,y,buf);
  20. }
  21. /******************************************************
  22.     数値プリント(ito4a付き)
  23. ******************************************************/
  24. void    p_12_ito4a(x,y,d)
  25. int    x,y,d;
  26. {
  27. char    buf[16];
  28. ito4a(d,buf);
  29. p_12W(x,y,buf);
  30. }
  31. /******************************************************
  32.     数値プリント(sprintf付き)
  33. ******************************************************/
  34. void    p_12_sprintf(x,y,str,d1,d2,d3)
  35. int    x,y,d1,d2,d3;
  36. UNchar    *str;
  37. {
  38. char    buf[100];
  39. sprintf(buf,str,d1,d2,d3);
  40. p_12W(x,y,buf);
  41. }
  42. /******************************************************
  43.     数値プリント(sprintf付き)
  44. ******************************************************/
  45. void    p_12_sprintf_double(x,y,str,d1,d2)
  46. int    x,y;
  47. double    d1,d2;
  48. UNchar    *str;
  49. {
  50. char    buf[100];
  51. sprintf(buf,str,d1,d2);
  52. p_12W(x,y,buf);
  53. }
  54. /*****************************************************
  55.         背景(白)付き12dot 文字列表示
  56. *****************************************************/
  57. int    p_12W(x,y,st)
  58. int    x,y;
  59. UNchar    *st;
  60. {
  61. int    l;
  62. struct _fillptr PP;
  63. l=jstrlen_(st);
  64. PP.x1=x;
  65. PP.y1=y;
  66. PP.x2=x+l*6-1;
  67. PP.y2=y+12-1;
  68. PP.color=PalTable[15];
  69. //            CRTVDISP();
  70. _iocs_fill(&PP);
  71. return( p_12H(x,y,st) );
  72. }
  73. /*****************************************************
  74.                12ドット文プリント
  75. *****************************************************/
  76. int    p_12H(x,y,st)
  77. int    x,y;
  78. UNchar    *st;
  79. {
  80. int    l;
  81. int    ssp;
  82. struct FNTBUF    FB;
  83. ssp=_iocs_b_super(0);
  84. GGCHAR_COLOR1=RGB(1,1,1);
  85. while( l=*(st++) ){
  86.     if ( ZenChk(l) )
  87.         l=(l*0x100)+(*st++);
  88.     FNTGET12(l,&FB);
  89.     GGCHAR_S(VADDS(0,x,y),&FB);
  90.     x+=FB.xl;
  91. }
  92. if ( ssp>=0 )
  93.     _iocs_b_super(ssp);
  94. return(0);
  95. }
  96. /*****************************************************
  97.                影付き16ドット文プリント
  98. *****************************************************/
  99. int    p_16K(x,y,st)
  100. int    x,y;
  101. UNchar    *st;
  102. {
  103. int    l;
  104. int    ssp;
  105. struct _fntbuf    FB;
  106. ssp=_iocs_b_super(0);
  107. while( l=*(st++) ){
  108.     if ( ZenChk(l) )
  109.         l=(l*0x100)+(*st++);
  110.     //_iocs_fntget(8,l,&FB);
  111.     FNTGET(8,l,&FB);
  112.     GGCHAR_COLOR1=RGB(1,1,1);
  113.     GGCHAR_S(VADDS(0,x+1,y+1),(void*)&FB);
  114.     GGCHAR_COLOR1=RGB(31,31,31);
  115.     GGCHAR_S(VADDS(0,x,y),(void*)&FB);
  116.     x+=FB.xl;
  117. }
  118. if ( ssp>=0 )
  119.     _iocs_b_super(ssp);
  120. GGCHAR_COLOR1=RGB(1,1,1);
  121. return(0);
  122. }
  123. /*****************************************************
  124.                影付き12ドット文プリント
  125. *****************************************************/
  126. int    p_12K(x,y,st)
  127. int    x,y;
  128. UNchar    *st;
  129. {
  130. int    l;
  131. int    ssp;
  132. struct FNTBUF    FB;
  133. ssp=_iocs_b_super(0);
  134. while( l=*(st++) ){
  135.     if ( ZenChk(l) )
  136.         l=(l*0x100)+(*st++);
  137.     FNTGET12(l,&FB);
  138.     //_iocs_fntget(6,l,&FB);
  139.     GGCHAR_COLOR1=RGB(31,31,31);
  140.     GGCHAR_S(VADDS(0,x+1,y+1),&FB);
  141.     GGCHAR_COLOR1=0x4210;
  142.     GGCHAR_S(VADDS(0,x,y),&FB);
  143.     x+=FB.xl;
  144. }
  145. if ( ssp>=0 )
  146.     _iocs_b_super(ssp);
  147. GGCHAR_COLOR1=RGB(31,31,31);
  148. return(0);
  149. }
  150. /*****************************************************
  151.                12ドット文テキストプリント
  152. *****************************************************/
  153. int    text_12H(x,y,st)
  154. int    x,y;
  155. UNchar    *st;
  156. {
  157. int    o,l;
  158. int    ssp;
  159. struct FNTBUF    FB;
  160. ssp=_iocs_b_super(0);
  161. o=*(UNshort*)0xe8002a;
  162. *(UNshort*)0xe8002a=0x00;
  163. while( l=*(st++) ){
  164.     if ( ZenChk(l) )
  165.         l=(l*0x100)+(*st++);
  166.     FNTGET12(l,&FB);
  167.     if ( FB.xl==6 )
  168.         TXHMOJI_S(x,y,&FB);
  169.     else    TXZMOJI_S(x,y,&FB);
  170.     x+=FB.xl;
  171. }
  172. *(UNshort*)0xe8002a=o;
  173. if ( ssp>=0 )
  174.     _iocs_b_super(ssp);
  175. return(0);
  176. }
  177. /*************************************************
  178.               intを2文字列に
  179. *************************************************/
  180. void    ito2a(i,st)
  181. int    i;
  182. UNchar    *st;
  183. {
  184. int    k;
  185. k=DIVU(i,10);    *st++=( k )?k+'0':' ';
  186.         *st++=MODU(i,10)+'0';
  187.         *st  =0;
  188. }
  189. /*************************************************
  190.               intを3文字列に
  191. *************************************************/
  192. void    ito3a(i,st)
  193. int    i;
  194. UNchar    *st;
  195. {
  196. int    l,k;
  197. l=DIVU(i,100);            *st++=( l )?l+'0':' ';
  198. k=DIVU(i,10);k-=MULU(l,10);    *st++=( k )?k+'0':( l )?'0':' ';
  199.                 *st++=MODU(i,10)+'0';
  200.                 *st  =0;
  201. }
  202. /*************************************************
  203.               intを4文字列に
  204. *************************************************/
  205. void    ito4a(i,st)
  206. int    i;
  207. UNchar    *st;
  208. {
  209. int    j,l,k;
  210. j=DIVU(i,1000);            *st++=( j )?j+'0':' ';
  211. l=DIVU(i,100); l=MODU(l,10);    *st++=( l )?l+'0':( j )?'0':' ';
  212. k=DIVU(i,10); k=MODU(k,10);    *st++=( k )?k+'0':( l )?'0':( j )?'0':' ';
  213.                 *st++=MODU(i,10)+'0';
  214.                 *st  =0;
  215. }
  216. /*************************************************
  217.               intを5文字列に
  218. *************************************************/
  219. void    ito5a(i,st)
  220. int    i;
  221. UNchar    *st;
  222. {
  223. int    a,j,l,k;
  224. a=DIVU(i,10000);        *st++=( a )?a+'0':' ';
  225. j=DIVU(i,1000);j=MODU(j,10);    *st++=( j )?j+'0':( a )?'0':' ';
  226. l=DIVU(i,100); l=MODU(l,10);    *st++=( l )?l+'0':( j )?'0':( a )?'0':' ';
  227. k=DIVU(i,10); k=MODU(k,10);    *st++=( k )?k+'0':( l )?'0':( j )?'0':( a )?'0':' ';
  228.                 *st++=MODU(i,10)+'0';
  229.                 *st  =0;
  230. }
  231. /*************************************************
  232.              漢字を含む文字列の複製
  233. *************************************************/
  234. char    *jstrcpy(sou,des)
  235. UNchar    *sou,*des;
  236. {
  237. UNchar    c;
  238. UNchar    *r=sou;
  239. while( c=(*(sou++)=*(des++)) )
  240.     if ( ZenChk(c) )
  241.         *(sou++)=*(des++);
  242. return(r);
  243. }
  244. /*************************************************
  245.             漢字を含む文字列の連結
  246. *************************************************/
  247. char    *jstrcat(sou,des)
  248. UNchar    *sou,*des;
  249. {
  250. UNchar    c;
  251. UNchar    *r=sou;
  252. while( c=*(sou) ){
  253.     sou++;
  254.     if ( ZenChk(c) )
  255.         sou++;
  256. }
  257. while( c=(*(sou++)=*(des++)) )
  258.     if ( ZenChk(c) )
  259.         *(sou++)=*(des++);
  260. return(r);
  261. }
  262. /*************************************************
  263.               漢字を含む文字列長(byte)
  264.        全角は2文字分
  265. *************************************************/
  266. int    jstrlen(st)
  267. UNchar    *st;
  268. {
  269. int    l,c;
  270. l=0;
  271. while( c=*(st++) ){
  272.     l++;
  273.     if ( ZenChk(c) ){
  274.         l++;    st++;
  275.     }
  276. }
  277. return(l);
  278. }
  279. /*************************************************
  280.               漢字を含む文字列長(文字幅)
  281.        全角は2文字分
  282. *************************************************/
  283. int    jstrlen_(st)
  284. UNchar    *st;
  285. {
  286. int    l,c;
  287. l=0;
  288. while( c=*(st++) ){
  289.     l++;
  290.     if ( ZenChk(c) ){
  291.         if ( c>0x80 && c<0xF0 )
  292.             l++;
  293.         st++;
  294.     }
  295. }
  296. return(l);
  297. }
  298. /*************************************************
  299.             漢字を含む文字列長(文字幅,TAB考慮)
  300.        全角は2文字分
  301. *************************************************/
  302. int    jstrlen_tb(st)
  303. UNchar    *st;
  304. {
  305. int    l,c;
  306. l=0;
  307. while( c=*(st++) ){
  308.     if ( c==0x0d || c==0x0a || c==0x1a )
  309.         break;
  310.     if ( c=='\t' ){
  311.         do{
  312.             l++;
  313.         } while ( l % 8 );
  314.         continue;
  315.     }
  316.     l++;
  317.     if ( ZenChk(c) ){
  318.         if ( c>0x80 && c<0xF0 )
  319.             l++;
  320.         st++;
  321.     }
  322. }
  323. return(l);
  324. }
  325. /*************************************************
  326.  漢字を含む文字列の半角英字小文字を大文字にします
  327.        全角は2文字分
  328. *************************************************/
  329. int    jstrupr(st)
  330. UNchar    *st;
  331. {
  332. int    c;
  333. UNchar    *r=st;
  334. while( c=*st ){
  335.     if ( ZenChk(c) )
  336.         st++;
  337.     elif ( c>=0x61 && c<=0x7A )
  338.         *st=c-0x20;
  339.     st++;
  340. }
  341. return((int)r);
  342. }
  343. /*************************************************
  344.  漢字を含む文字列の比較をします
  345. (半角英字は大文字小文字区別されません))
  346. *************************************************/
  347. int    jstrcmpi(st1,st2)
  348. UNchar    *st1,*st2;
  349. {
  350. int    c,c1,c2;
  351. do {
  352.     c1=*st1++;
  353.     if ( ZenChk(c1) ){
  354.         /*[1]は全角*/
  355.         c2=*st2++;
  356.         if ( c1<c2 )    return(-1);
  357.         if ( c1>c2 )    return(1);
  358.         if ( ZenChk(c2)==0 )
  359.             return(1);    /*[2]は全角じゃない*/
  360.         c=*st1++;
  361.         c2=*st2++;
  362.         if ( c<c2 )    return(-1);
  363.         if ( c>c2 )    return(1);
  364.         c1=c1*0x100+c;
  365.     } else {
  366.         /*[1]は半角*/
  367.         c2=*st2++;
  368.         if ( ZenChk(c2)!=0 )
  369.             return(-1);    /*[2]は全角だ*/
  370.         if ( c1>='A' && c1<='Z' ) c1|=0x20;
  371.         if ( c2>='A' && c2<='Z' ) c2|=0x20;
  372.         if ( c1<c2 )    return(-1);
  373.         if ( c1>c2 )    return(1);
  374.     }
  375. } while( c1!=0 );
  376. return(0);
  377. }
  378. /**************************************************
  379.     全角チェック)
  380. [戻り値] 0 : 半角
  381.      1 : 全角
  382. **************************************************/
  383. int    ZenChk(c)
  384. int    c;
  385. {
  386. return( (c>=0x80 && c<=0x9f) || c>=0xE0 );
  387. }
  388. /*************************************************
  389.         ダイアログ表示
  390. [in]    *s1,*s2,*s3 表示文字列
  391.     md=-1; 表示を消す
  392.     md= 0; 待ちなし
  393.     md= 1; 確認
  394.     md= 2; 選択
  395. [out] md==2 の場合のみ。
  396.      0 ; 選択
  397.     -1 ; 中止
  398. *************************************************/
  399. int    Dialog(s1,s2,s3,md)
  400. UNchar    *s1,*s2,*s3;
  401. int    md;
  402. {
  403. int    i,b,r;
  404. int    xx,yy;
  405. int    ssp;
  406. extern    UNchar    diabak[165*205*2];    // ダイアログ用のバッファ
  407. struct _fillptr PP;
  408. struct _getptr GP;
  409. GP.buf_start=&diabak[0];
  410. GP.buf_end=&diabak[165*205*2-1];
  411. PP.x1 = GP.x1 = 2*16;
  412. PP.y1 = GP.y1 = 10*16;
  413. PP.x2 = GP.x2 = GP.x1+12*16+8;
  414. PP.y2 = GP.y2 = GP.y1+10*16;
  415. //--
  416. if ( md<0 ){
  417.     // 消す(前に「待ちなし」を実行していること)
  418.     _iocs_putgrm( (void*)&GP );
  419.     return(0);
  420. }
  421. //-- 記憶
  422. _iocs_getgrm( &GP );
  423. //-- ベタ書く
  424. PP.color=PalTable[14];
  425. _iocs_fill(&PP);
  426. //-- 枠(白)書く
  427. PP.x1=2*16;
  428. PP.y1=10*16;
  429. PP.x2=PP.x1+1;
  430. PP.y2=PP.y1+10*16;
  431. PP.color=PalTable[15];
  432. _iocs_fill(&PP);
  433. PP.x2=PP.x1+12*16+8;
  434. PP.y2=PP.y1+1;
  435. _iocs_fill(&PP);
  436. //-- 枠(影)書く
  437. PP.x1=2*16+12*16+8-1;
  438. PP.y1=10*16+1;
  439. PP.x2=PP.x1+1;
  440. PP.y2=PP.y1+10*16-1;
  441. PP.color=PalTable[10];
  442. _iocs_fill(&PP);
  443. PP.x1=2*16+1;
  444. PP.y1=10*16+10*16-1;
  445. PP.x2=PP.x1+12*16+8-1;
  446. PP.y2=PP.y1+1;
  447. _iocs_fill(&PP);
  448. //--
  449. if ( s1!=0 )
  450.     p_12H(4*16,11*16,s1);
  451. if ( s2!=0 )
  452.     p_12H(4*16,13*16,s2);
  453. if ( s3!=0 )
  454.     p_12H(4*16,15*16,s3);
  455. if ( md==0 )
  456.     return(0);
  457. while( MS_LSW()!=0 || MS_RSW()!=0 );
  458. ssp=_iocs_b_super(0);
  459. if ( md==1 ){
  460.     // 確認のみ
  461.     GGSP16_64_S(TADDS(12,17),0x48);
  462.     GGSP16_64_S(TADDS(13,17),0x49);
  463.     GGSP16_64_S(TADDS(12,18),0x50);
  464.     GGSP16_64_S(TADDS(13,18),0x51);
  465.     /*
  466.     PP.x=12*16;
  467.     PP.y=17*16;
  468.     PP.x1=32*1;
  469.     PP.y1=32*1;
  470.     PP.vram_page=0x8003;
  471.     PP.fill_patn=0x0000;
  472.     _iocs_txfill(&PP);
  473.     */
  474. } else {
  475.     // 選択
  476.     GGSP16_64_S(TADDS(10,17),0x48);
  477.     GGSP16_64_S(TADDS(11,17),0x49);
  478.     GGSP16_64_S(TADDS(10,18),0x50);
  479.     GGSP16_64_S(TADDS(11,18),0x51);
  480.     GGSP16_64_S(TADDS(12,17),0x4a);
  481.     GGSP16_64_S(TADDS(13,17),0x4b);
  482.     GGSP16_64_S(TADDS(12,18),0x52);
  483.     GGSP16_64_S(TADDS(13,18),0x53);
  484.     /*
  485.     PP.x=10*16;
  486.     PP.y=17*16;
  487.     PP.x1=32*2;
  488.     PP.y1=32*1;
  489.     PP.vram_page=0x8003;
  490.     PP.fill_patn=0x0000;
  491.     _iocs_txfill(&PP);
  492.     */
  493. }
  494. if ( ssp>0 )
  495.     _iocs_b_super(ssp);
  496. //_iocs_sp_on();
  497. MsPat(1);
  498. for(;;){
  499.     do {
  500.         yy=( i=_iocs_ms_curgt() )&0xFFFF;
  501.         xx=i>>16;
  502.         //_iocs_sp_regst(0,bit(31),xx+16  ,yy+16  ,1,1);
  503.         if ( (_iocs_bitsns(3)&bit(5))!=0 )
  504.             break;
  505.         if ( (_iocs_bitsns(9)&bit(6))!=0 )
  506.             break;
  507.         if ( (_iocs_bitsns(1)&bit(0))!=0 )
  508.             break;
  509.     } while( MS_LSW()==0 && (b=MS_RSW())==0 );
  510.     if ( (_iocs_bitsns(3)&bit(5))!=0 || (_iocs_bitsns(9)&bit(6))!=0 ){
  511.         r=0;
  512.         while( (_iocs_bitsns(3)&bit(5))!=0 || (_iocs_bitsns(9)&bit(6))!=0 );
  513.         break;
  514.     }
  515.     if ( (_iocs_bitsns(1)&bit(0))!=0 ){
  516.         r=-1;
  517.         while( (_iocs_bitsns(1)&bit(0))!=0 );
  518.         break;
  519.     }
  520.     if ( b!=0 ){
  521.         if ( md==2 ){
  522.             r=-1;
  523.             break;
  524.         }
  525.         continue;
  526.     }
  527.     if ( yy<17*16 || yy>=19*16 )
  528.         continue;
  529.     if ( xx>=12*16 && xx<14*16 ){
  530.         if ( sxbotton(12*16,17*16,14*16-1,19*16-1,1)==0 ){
  531.             r=-1;
  532.             break;
  533.         }
  534.     } elif ( md==2 && xx>=10*16 && xx<12*16 ){
  535.         if ( sxbotton(10*16,17*16,12*16-1,19*16-1,1)==0 ){
  536.             r=0;
  537.             break;
  538.         }
  539.     }
  540. }
  541. _iocs_putgrm( (void*)&GP );
  542. return(r);
  543. }
  544. /*************************************************
  545.         DUMP
  546. *************************************************/
  547. void    dumps(bb,ll)
  548. UNchar    *bb;
  549. int    ll;
  550. {
  551. int    i,j,m,n,c;
  552. for(j=0;j<ll;j+=16){
  553.     for(i=0;i<16;i++){
  554.         n=j+i;
  555.         if ( n>=ll )
  556.             break;
  557.         printf("%02X ",bb[n]);
  558.     }
  559.     printf("   ");
  560.  
  561.     for(i=0;i<16;i++){
  562.         n=j+i;
  563.         if ( n>=ll )
  564.             break;
  565.         c=bb[n];
  566.         if ( c<0x20 )
  567.             c='.';
  568.         else if ( c>=0x80 && c<=0x9F )
  569.             c='.';
  570.         else if ( c>=0xE0 )
  571.             c='.';
  572.         putchar(c);
  573.     }
  574.     printf("\n");
  575. }
  576. return;
  577. }
  578.